//
//  EarlyRedemptionViewController.m
//  TenThousand
//
//  Created by 我的 on 16/7/18.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "EarlyRedemptionViewController.h"
#import "MyTouziViewController.h"

@interface EarlyRedemptionViewController ()<UIAlertViewDelegate>

@end

@implementation EarlyRedemptionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createLeft:[UIImage imageNamed:@"ZHSZicon_03"] leftClick:^{
        [self.navigationController popViewControllerAnimated:YES];
    } right:nil rightClick:nil];
    self.navigationItem.title = @"提前赎回";
}



- (IBAction)sureRed:(id)sender {
    
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"是否确认提前赎回?" message:@"温馨提示:赎回金额将会在1-7个工作日内到账,请及时查收!" delegate: nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    alert.delegate = self;
    [alert show];
    
//     [self getAddredemption];

}

//跳转
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
  

    [self getAddredemption];
    
    
}


//提前赎回
-(void)getAddredemption{
    
    /**
     *  BorrowListId  投资编号
     *  LoginName     用户编号
     */
    NSString *loginName = [[NSUserDefaults standardUserDefaults] objectForKey:@"LoginId"];
    
    NSDictionary *para = @{
                           @"BorrowListId":_BorrowListId,
                           @"LoginName":loginName
                           };
    
    
    [NetWorkManager requestWithType:HttpRequestTypePost withMethodName:@"Redemp.GetAddredemption" withParaments:para withSuccessBlock:^(NSDictionary *object) {
        
        NSLog(@"%@",object);
        if ([object[@"Code"] isEqualToString:@"00000"]) {
         
            [ToastView showInfoWithStatus:object[@"Message"]];
            
            [self.navigationController popToRootViewControllerAnimated:YES];
            
        }else
                
        [ToastView showInfoWithStatus:object[@"Message"]];
        
    } withFailureBlock:^(NSError *error) {
        NSLog(@"%@",error);
    } progress:nil];
}


@end
